package GreedyThought;

import java.util.Arrays;

// Lettcode 455: https://leetcode-cn.com/problems/assign-cookies/
public class findContentChildren {
    public int findContentChildren(int[] g, int[] s) {
        int res = 0;
        if (g == null || s == null) return 0;
        Arrays.sort(g);
        Arrays.sort(s);
        int posG = 0;
        int posS = 0;
        while (posG < g.length && posS < s.length) {
            if (g[posG] <= s[posS]) {
                posG++;
                res += 1;
            }
            posS++;
        }
        return res;
    }
}
